Here is a snippet of code;
I want to overload the [] operator such that, when I try to do something like
vCont[i]->name
it should check the mask against Contmask and take specific action.
For example:
vCont contents are
vCont[0]->mask = 0x1;
vCont[1]->mask = 0x2;
vCont[2]->mask = 0x2;
If Contmask = 0x2, then only vCont[1] and vCont[2] have to be accessed.
So, is it possible to overload the [] operator so that it prints out an error message.
Code:class Base { unsigned int mask; string name; }; class Cont { unsigned int contmask; vector<Base *> vCont; };